#ifndef _QUADTREENODE_H_
#define _QUADTREENODE_H_

#include "AxisAlignedBox.h"

namespace QuadTreeLib
{

struct LODSelection;

class QuadTreeNode
{
protected:
	QuadTreeNode* mChild[4];
	AABB mAABB;
	size_t mLodLevel;
	Vector3 mPosition;
	float mSize;

public:
	enum LODSelectResult
	{
		LOD_Undefined,
		LOD_OutOfFrustum,
		LOD_OutOfRange,
		LOD_Selected,
	};

	QuadTreeNode(size_t lodLevel, float size, const AABB& aabb)
		: mLodLevel(lodLevel)
		, mSize(size)
		, mAABB(aabb)
	{
		mChild[0] = 0;
		mChild[1] = 0;
		mChild[2] = 0;
		mChild[3] = 0;
	}

	QuadTreeNode(size_t lodLevel, float size)
		: mLodLevel(lodLevel)
		, mSize(size)
	{
		mChild[0] = 0;
		mChild[1] = 0;
		mChild[2] = 0;
		mChild[3] = 0;
	}

	~QuadTreeNode()
	{
		for(int i=0; i<4; i++)
		{
			if (mChild[i])
			{
				delete mChild[i];
				mChild[i] = 0;
			}
		}
	}	
	LODSelectResult LODSelect(LODSelection& lodSelection, bool parentInFrustum);

protected:
	void createChildren(size_t lodLevel);
};

} // namespace QuadTreeLib
#endif